package Xuanke;


public class Course {

    private Student[] students;
    private String coursePlace;
    private String couseTime;
    private int id;
    private String Name;

    //构造函数
    public Course(int id, String Name, String coursePlace, String couseTime) {
        super();
        this.id=id;
        this.Name=Name;
        this.coursePlace=coursePlace;
        this.couseTime=couseTime;
        students = new Student[1];
    }


    public Course() {//默认形式，要有以防万一
        super();
        students = new Student[1];
    }

    //修改或获取属性值id，name，credit，
    public void setId(int id) {
        this.id = id;
    }

    public int getId() {
        return this.id;
    }

    public void setName(String name) {
        this.Name = name;
    }

    public String getName() {
        return this.Name;
    }



    //课加入学生
    public boolean addStudent(Student stu) {
        boolean flag = false;//标志值：是否加入成功
        if (!isSelectedStudent(stu) && isNullStudent(stu)) {
            for (int i = 0; i < students.length; i++) {
                if (students[i] == null) {
                    students[i] = stu;
                    flag = true;
                    break;
                }
            }
            return flag;
        }
        return flag;
    }

    private boolean isNullStudent(Student stu) {
        // TODO Auto-generated method stub
        return false;
    }

    //课移除学生
    public boolean removeStudent(Student stu) {
        boolean flag = false;
        if (isSelectedStudent(stu)) {//选过这门课
            for (int i = 0; i < students.length; i++) {
                if (students[i] == stu) {
                    students[i] = null;
                    flag = true;
                    break;
                }
            }
            return flag;
        }
        return flag;
    }

    private boolean isSelectedStudent(Student stu) {
        // TODO Auto-generated method stub
        return false;
    }

    public String toString(){
        return "课程号："+id+"  课程名称："+Name+"  地点："+coursePlace+"  时间："+couseTime;
    }


}